home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (C) 1989, 1990 Aladdin Enterprises. All rights reserved.
- Distributed by Free Software Foundation, Inc.
-
- This file is part of Ghostscript.
-
- Ghostscript is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
- to anyone for the consequences of using it or for whether it serves any
- particular purpose or works at all, unless he says so in writing. Refer
- to the Ghostscript General Public License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- Ghostscript, but only under the conditions described in the Ghostscript
- General Public License. A copy of this license is supposed to have been
- given to you along with Ghostscript so you can know your rights and
- responsibilities. It should be in a file named COPYING. Among other
- things, the copyright notice and this notice must be preserved on all
- copies. */
-
- /* gp_dos.c */
- /* DOS-specific routines for Ghostscript */
- #define interrupt /* non-ANSI! */
- #pragma inline /* for assembly code, see below */
- #include <dos.h>
- #include <fcntl.h>
- #include "string_.h"
- #include "gx.h"
-
- /* Define the size of the C stack. */
- unsigned _stklen = 8000; /* default is 4096, we need more */
-
- /* Do platform-dependent initialization */
- void
- gp_init()
- { /*
- * Detect the processor type using the following algorithms:
- * The 8088/8086 truncate shift counts mod 32,
- * the 80186 and up do not.
- * The 80186 and below fix FLAGS bits 15-12 to 1,
- * the 80286 and up do not.
- * The 80386 allows setting FLAGS bits 14-12,
- * the 80286 and below do not.
- * Note that this algorithm will identify an 80386
- * running in Virtual 8086 mode as an 80386.
- * This is acceptable, because Ghostscript doesn't actually
- * use 80286 or 80386 addressing modes, only the additional
- * instructions available on these processors.
- * (This algorithm is derived from the Intel manuals.)
- */
- #if CPU_TYPE > 86
- /* We have to be careful not to turn interrupts off! */
- int result, type;
- { asm mov ax,202h; asm push ax; asm popf;
- asm pushf; asm pop result;
- }
- if ( (result & 0xf000) == 0xf000 )
- { /* CPU is an 8088/8086/80186 */
- { asm mov cl,33; asm mov ax,0ffffh;
- asm shl ax,cl; asm mov result,ax;
- }
- type = (result == 0 ? 186 : 86);
- }
- else
- { /* CPU is an 80286/80386/... */
- { asm mov ax,7202h; asm push ax; asm popf;
- asm pushf; asm pop result;
- }
- type = ((result & 0x7000) == 0 ? 286 : 386);
- }
- if ( type < CPU_TYPE )
- { eprintf1("This executable requires an 80%d or higher.\n", CPU_TYPE);
- exit(1);
- }
- #endif
- _fmode = O_BINARY; /* Open files in 'binary' mode */
- }
-
- /* Read the current date (in days since Jan. 1, 1980) */
- /* and time (in milliseconds since midnight). */
- void
- gs_get_clock(long *pdt)
- { struct date osdate;
- struct time ostime;
- long idate;
- static int mstart[12] =
- { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
- getdate(&osdate);
- gettime(&ostime);
- idate = (long)osdate.da_year * 365 +
- (osdate.da_year / 4 + 1 + /* account for leap years */
- mstart[osdate.da_mon - 1] + /* month is 1-origin */
- osdate.da_day - 1); /* day of month is 1-origin */
- if ( osdate.da_mon <= 2 && osdate.da_year % 4 == 0 ) /* Jan. or Feb. of leap year */
- idate--;
- pdt[0] = idate;
- pdt[1] =
- (ostime.ti_hour * 60 + ostime.ti_min) * 60000L +
- (ostime.ti_sec * 100 + ostime.ti_hund) * 10L;
- }
-
- /* ------ File name syntax ------ */
-
- /* Define the character used for separating file names in a list. */
- char gp_file_name_list_separator = '|';
-
- /* Answer whether a file name contains a directory/device specification, */
- /* i.e. is absolute (not directory- or device-relative). */
- int
- gp_file_name_is_absolute(char *fname, uint len)
- { /* A file name is absolute if it contains a drive specification */
- /* (second character is a :) or if it start with / or \. */
- return ( len >= 1 && (*fname == '/' || *fname == '\\' ||
- (len >= 2 && fname[1] == ':')) );
- }
-
- /* Answer the string to be used for combining a directory/device prefix */
- /* with a base file name. The file name is known to not be absolute. */
- char *
- gp_file_name_concat_string(char *prefix, uint plen, char *fname, uint len)
- { if ( plen > 0 )
- switch ( prefix[plen - 1] )
- { case ':': case '/': case '\\': return "";
- };
- return "\\";
- }
-